<template>
	<view class="content">

		<okingtz-cropper @uploadSuccess="uploadSuccess" :image="img" :maxCropper="true" :quality="1">
		</okingtz-cropper>

	</view>
</template>

<script>
	//  1.引入项目
	import OkingtzCropper from '../../../components/okingtz-cropper/okingtz-cropper'
	
	export default {
		components: {
			//2.使用组件
			OkingtzCropper
		},
		


		data() {
			return {
				img: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fup.enterdesk.com%2Fedpic%2Ff6%2Fc9%2Ff6%2Ff6c9f647a533782026c0609ac5d550df.jpg',
				newData: {

				},
				
			}
		},

		methods: {
			// 3.定义自己的回调函数
			uploadSuccess(tempFilePath) {
				
				uni.uploadFile({
					url: this.baseUploadUrl,
					filePath: tempFilePath,
					name: 'file',
					header: {
						'token': uni.getStorageSync('token')
					},
					success: (uploadFileRes) => {
						console.log(uploadFileRes);
						let oldUrl = img

						// this.newData = JSON.parse(uploadFileRes.data)
						// let newUserinfo = this.userinfo
						// newUserinfo.faceImage = this.newData.data
						// this.$store.dispatch('set_userinfo', newUserinfo)
						// uni.showToast({
						// 	title: '保存成功',
						// 	icon: 'none'
						// });
						// setTimeout(function() {
						// 	uni.switchTab({
						// 		url: '../info/info'
						// 	})
						// }, 2000);

					}
				});


			}
		}
	}
</script>

<style>

</style>
